/** Part of Zombie Navigator
	Copyright © 2016  Zombie Navigator Developers
	
	@file
	@module
	@license AGPL-3.0+
	
*/ 'use strict';


/* Used modules */
const _pLogger = require('../platform/logger');

const _stackLimit = 10;

/**
	Handle an error from a Zombie script
	@public
*/
const print = function (... errors) {
	const pLogger = _pLogger;
	const stackLimit = _stackLimit;
	
	for (let e of errors) {
		const messages = ['Script failed:'];
		messages.push('' + e);
		
		if ('stack' in e) {
			const stack = ('' + e.stack)
				.split("\n").slice(0, stackLimit).join("\n\t");
			messages.push('Stack: \n\t' + stack);
		}
		
		pLogger.error(... messages);
	}
};


/* Exports */
exports.print = print;


// vim: ts=4 noet ai

